/**
 * Created by zhangzhihao on 2016/12/06 11:00;
 */
var vm = new Vue({
    el: "#main",
    data: {
        listArry: [],  // 列表信息
        opt_name: "", // 申请人
        req_detail: "", // 申请事项
        nowPage:1,
        rowNum:10,
        allPages:0,
        pagination: [],
        jumpPage:'',
        tipMsg: '',
    },
    created: function() {
        this.queryApplyList();
    },
    methods: {
         //分页
         selectPage(page){
            this.nowPage = page;
            this.queryApplyList();
        },
        skipPage() {
        	this.nowPage = parseInt(document.getElementById('page-num').value);
        	document.getElementById('page-num').value = '';
            this.queryApplyList();
        },
        offsetPage(offset){
            this.nowPage = parseInt(this.nowPage) + parseInt(offset);
            this.queryApplyList();
        },
        queryApplyList() {
            const _this = this;
            _this.listArry = [];
            let obj = {
                optName: this.opt_name,
                reqDetail: this.req_detail,
                nowPage:this.nowPage,
                rowNum:this.rowNum,
                appType:'0'
            }
            axios({
                method: "post",
                url: App.envUrl.backtrackUrl+"approval/query",
                data: obj,
            }).then((data) => {
                if (data.data.code == '200') {
                    var list = data.data.pageCount.datas;
                    if(list.length > 0){
                        this.allPages = data.data.pageCount.allPages;
                        this.pagination = getPagination(this.nowPage,this.allPages);
                        list.forEach((element) => {
                            element.stateValue = "";
                            if (element.status == 0) {
                                element.stateValue = "未审核";
                            } else if (element.status == 1) {
                                element.stateValue = "通过";
                            } else if (element.status == 2) {
                                element.stateValue = "拒绝";
                            } else if (element.status == 3) {
                                element.stateValue = "审核中";
                            }
                        });
                        _this.listArry = list;
                    }else if(list.length == 0) {
                        _this.tipMsg = '抱歉，未查询到符合条件的数据！'
                        $('#my-alert1').modal({
                            relatedTarget: _this,
                        });
                        _this.listArry = [];
                    }
                }
            }).catch((err) => {
            	_this.tipMsg = '抱歉，查询失败！'
                $('#my-alert1').modal({
                    relatedTarget: _this,
                });
            })
        },
        resetBtn() {
            this.opt_name = "";
            this.req_detail = "";
			this.listArry = []
        },
        approveBrrback(reqId,status,approval) {
            window.location.href = 'nrrbackApprove.html?req_id=' + reqId + '&status='+ status + '&approval=' +approval
        }
    }
});